/*
 * Main.java
 *
 * Created on 27 febbraio 2007, 22.36
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package com.bloomingstars.bluepad.desktop.client;

import com.bloomingstars.bluepad.comm.CommType;
import com.bloomingstars.bluepad.comm.CommandCode;
import com.bloomingstars.bluepad.comm.DA2Address;
import com.bloomingstars.bluepad.comm.DA2Comm;
import com.bloomingstars.bluepad.comm.DA2CommFactory;
import com.bloomingstars.bluepad.comm.DA2CommListener;
import com.bloomingstars.bluepad.comm.SetupStatus;

/**
 *
 * @author toni
 */
public final class Main
{    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws InterruptedException
    {
        System.out.println("Bluepad Client is starting...");
        
        Thread t = new Thread(new Runnable()
        {            
            public void run()
            {
                /*BluePadDiscoverer bluePadDiscoverer = new BluePadDiscoverer();
                bluePadDiscoverer.execute();*/
                DA2Comm comm = DA2CommFactory.createDA2Comm(CommType.BLUETOOTH);
                DA2Address address = new DA2Address("", "da2");
                
                int setupStatus = comm.setup(address);

                comm.addCommListener(new DA2CommListener()
                {
                    public void dataReceived(String s, int cmd)
                    {
                        System.out.println("Listener - Data received: " + s + " " + cmd);
                    }
                    
                    public void connectionLost()
                    {
                        System.out.println("Connection lost!");
                    }
                });
                
                System.out.println("Setup status: " + setupStatus);
                
                comm.connect();
                
                comm.send(CommandCode.SET_SPEED_1);
                try
                {
                  Thread.sleep(2000);
                }
                catch (Exception ex)
                {
                    
                }
                comm.send(CommandCode.GET_TELESCOPE_RA);
                try
                {
                  Thread.sleep(2000);
                }
                catch (Exception ex)
                {
                    
                }
                comm.send(CommandCode.GET_TELESCOPE_DEC);
                try
                {
                  Thread.sleep(2000);
                }
                catch (Exception ex)
                {
                    
                }
                
                
                comm.disconnect();
            }
        });           
    }
    
}